<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>14-短信倒计时</title>
		<script type="text/javascript" src="js/jquery2.1.4.js"></script>
			
		
	</head>
	<body>
		<input type="text" name='mobile' placeholder="请输入手机号"><button>发送</button>
		<script type="text/javascript">
			var oinput = document.querySelector('input');
			var btn = document.querySelector('button');
			var time = 10;
			btn.onclick = function(){
				var mobile = oinput.value;
				//发送
				$.ajax({
					url:'https://cache.iminutes.cn/api/soft/send.html',
					type:'POST',
					data:{
						mobile:mobile
					},
					dataType:'json',
					success:function(res){
						console.log(res);
					}
				});
				//约束时长
				
				console.log('时间::'+time);
				var timer = setInterval(function(){
					btn.disabled=false;
					if(time==0){
						clearInterval(timer);
						btn.innerHTML = '发送';
					}else{
						btn.innerHTML = '正在发送,还剩'+time+'秒';
						time--;
						btn.disabled=true;					
					}
				},1000);
			}
			
		</script>
	</body>
</html>
